package com.cdream.basic.algorithm.leetcode.array;

import java.util.ArrayList;
import java.util.List;

/**
 * @author cdream
 * @date 2022/3/6
 */
public class Question2100 {
    public static void main(String[] args) {
        new Question2100().goodDaysToRobBank(new int[]{5, 3, 3, 5, 6}, 2);
    }

    public List<Integer> goodDaysToRobBank(int[] security, int time) {
        List<Integer> res = new ArrayList();
        for (int i = 0; i < security.length; i++) {
            if (isSuit(security, time, i)) {
                res.add(i);
            }
        }
        return res;
    }

    public boolean isSuit(int[] arr, int time, int cur) {
        int start = Math.max(0, cur - time);
        for (int i = start; i < cur; i++) {
            if (arr[i] < arr[i + 1]) {
                return false;
            }
        }
        int end = Math.min(arr.length - 1, cur + time);
        for (int i = cur; i < end; i++) {
            if (arr[i] > arr[i + 1]) {
                return false;
            }
        }
        return true;
    }
}
